package com.tianyi.sfzy1.service;

import com.tianyi.sfzy1.domain.Coursefavorite;
import com.tianyi.sfzy1.mapper.CoursefavoriteMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CoursefavoriteService {
    @Autowired
    private CoursefavoriteMapper coursefavoriteMapper;

    //新增
    public int insert(Coursefavorite record) {
        return coursefavoriteMapper.insert(record);
    }

    //查询所有
    public List<Coursefavorite> findAll(){
        return coursefavoriteMapper.findAll();
    }
    //根据id查询
    public Coursefavorite selectByPrimaryKey(int favoriteId){
        return coursefavoriteMapper.selectByPrimaryKey(favoriteId);
    }

    //修改
    public int updateByPrimaryKey(Coursefavorite record){
        return coursefavoriteMapper.updateByPrimaryKey(record);
    }

    //删除
    public int deleteByPrimaryKey(int favoriteId){
        return coursefavoriteMapper.deleteByPrimaryKey(favoriteId);
    }

   //小程序增加新收藏
   public int insertOne(int memberId,int courseId){
        return coursefavoriteMapper.insertOne(memberId,courseId);
   }

   //小程序删除收藏
   public int deleteOne(int memberId,int courseId){
        return coursefavoriteMapper.deleteOne(memberId,courseId);
   }

   //小程序根据用户和课程id
   public Coursefavorite find(int memberId,int courseId) {
        return coursefavoriteMapper.find(memberId,courseId);
   }

}
